<template>
  <el-dialog   :visible.sync="visible" :title="title"  width="500px"  :before-close="handleClose" :close-on-click-modal="false">

      <el-form ref="form1" :model="form1" :rules="rules1" label-width="80px">
        <el-form-item label="附加费用" prop="addcost">
          <el-input v-model="form1.addcost"  placeholder="请输入附加费用" maxlength="7"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1"  v-preventReClick="3000">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>

  </el-dialog>
</template>

<script>
  import {getBillBySendOrderId,} from "@/api/zyx/bill";
  import { onlyupd } from "@/api/zyx/sendorder";
  export default {
     data() {
       return {
         id:'',
         addcost:'',
          bill:{},
        visible: false,
        title:'',
         // 表单参数
         form1: {},
         rules1: {
           addcost: [
             { required: true, message: "附加费用不能为空", trigger: "change" }
           ],
         },
         }
     },
     methods:{
       checkCost(cost){
           return RegExp(/^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/).test(cost);
       },
       getname(){
         this.getDicts("zyx_devicetype").then(response => {
           this.devicetypeOptions = response.data;
           // this.zyxDevice=response.data.zyxDevice

           this.devicetypename= this.selectDictLabel(this.devicetypeOptions, this.zyxDevice.devicetype);

         });
       },
       getbilldetail(){
         getBillBySendOrderId(this.id).then(response => {
           this.bill = response.data;
         });
       },

       // 表单重置
       reset1() {
         this.form1 = {
           id: null,
           addcost: null,
         };
         this.addcost='',
         this.resetForm("form1");
       },
       // 取消按钮
       cancel1() {
         this.visible = false;
         this.reset1();
       },
       /** 提交按钮 */
       submitForm1() {
         this.$refs["form1"].validate(valid => {
           this.form1.id=this.id
           if (valid) {
             if(!this.checkCost(this.form1.addcost)){
             	// this.$tip.alert('请输入合法的金额数字，最多两位小数');
                this.msgError("请输入合法的金额数字，最多两位小数");
             	return false
             }
               onlyupd(this.form1).then(response => {
                 this.msgSuccess("保存成功");
                 this.visible = false;
                 this.$parent.getList();
               });
           }
         });
       },
     }
    }
</script>

<style>
   .tab  tr td { border:1px solid #000000; }
   .tdcontent{ text-align:left;width: 220px;padding-left: 10px;}
   .tdtitle{text-align: right;width: 120px;padding-right: 10px;font-weight: bold;}
   .tab  {  min-height: 40px; line-height: 40px; text-align: center; border-collapse: collapse; }
</style>
